﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace blackhouse.BlackApart.Data.Sql {
    internal class SqlReservationServiceSaveTransaction : ReservationServiceSaveTransaction {

        #region Fields

        private AdditionalServicesDataAccess dataAccess;

        #endregion

        #region Constructors

        public SqlReservationServiceSaveTransaction(AdditionalServicesDataAccess data) {
            this.dataAccess = data;
        }

        #endregion

        #region Methods

        public override int Save() {
            int orderId = this.dataAccess.AddServiceToReservation(this.reservationId, this.serviceId, this.price, this.clientReview);
            foreach (TransactionLine line in base.lines) {
                this.dataAccess.AddServiceItemToReservation(orderId, line.ForDate, line.Quantity, this.unitPrice);
            }
            return orderId;
        }

        #endregion

    }
}
